package com.manli.api.service;

import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.List;
import com.manli.api.pojo.Result;
import com.manli.api.util.ResultUtil;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import com.manli.api.dao.SysWechatConfigDao;
import com.manli.api.dto.SysWechatConfig;
import org.springframework.transaction.annotation.Transactional;


@Service("sysWechatConfigService")
public class SysWechatConfigService {
    @Autowired
    SysWechatConfigDao sysWechatConfigDao;

    
    public Result queryPage(Map<String, Object> params) {
        PageQuery<SysWechatConfig> page = sysWechatConfigDao.createQuery()
                .page(Long.parseLong(params.get("page").toString()),Long.parseLong(params.get("limit").toString()));
        return ResultUtil.success(page.getList(),page.getTotalRow());
    }

    
    public Result queryAll() {
        List<SysWechatConfig> list = sysWechatConfigDao.all();
        return ResultUtil.success(list);
    }

    
    public Result getById(Integer id) {
        SysWechatConfig sysWechatConfig = sysWechatConfigDao.single(id);
        return ResultUtil.success(sysWechatConfig);
    }

    @Transactional
    public Result save(SysWechatConfig sysWechatConfig) {
        sysWechatConfigDao.insert(sysWechatConfig);
        return ResultUtil.success();
    }

    @Transactional
    public Result updateById(SysWechatConfig sysWechatConfig) {
        sysWechatConfigDao.updateTemplateById(sysWechatConfig);
        return ResultUtil.success();
    }

    @Transactional
    public Result removeById(Integer id) {
        sysWechatConfigDao.deleteById(id);
        return ResultUtil.success();
    }

    @Transactional
    public Result removeByIds(List<Integer> ids) {
        for (Integer id:ids) {
            sysWechatConfigDao.deleteById(id);
        }
        return ResultUtil.success();
    }



}
